<template>
  <div class="navigation">
    <div class="mobile-nav">
      <img class="mobile-header-image" src="https://cdn2.weimob.com/saas/@assets/saas-fe-console-retail2/@1.172.0/static/images/nav-mobile-top.697bb5b1.png" alt="">
      <div class="mobile-footer">
        <div v-for="(fromitem,index) in form" :key="index" class="item">
          {{ fromitem.name }}
        </div>
      </div>
    </div>
    <div class="mobile-config">
      <div class="panel">
        <div class="colorScheme">导航配色</div>
        <div class="select-color">
          <div class="color-circle" style="background-color: rgb(250, 57, 45);" />
          <div class="color-circle" />
          <div class="main-color">修改</div>
        </div>
      </div>
      <a-form-model class="panel-from">
        <a-row class="panel-list" :gutter="[16,16]">
          <draggable v-model="form">
            <a-col v-for="(k, index) in form" :key="index" :span="12">
              <a-card :title="`导航${index+1}`" style="width: 100%" size="small" class="mall-card">
                <a-icon slot="extra" type="close" style="cursor: pointer;" />
                <a-form-model-item
                  v-bind="formItemLayout"
                  label="名称"
                  :required="false"
                >
                  <a-input
                    v-model="k.name"
                    placeholder="导航名称"
                    :max-length="4"
                  />
                </a-form-model-item>
                <a-form-model-item
                  v-bind="formItemLayout"
                  :required="false"
                >
                  <span slot="label">
                    链接
                    <a-tooltip title="外卖模板、视频模板、社区团购模板里导航不生效">
                      <a-icon type="question-circle" />
                    </a-tooltip>
                  </span>
                  <a-button type="link">
                    选择链接
                  </a-button>
                </a-form-model-item>
                <a-form-model-item
                  v-bind="formItemLayout"
                  label="图标"
                  :required="false"
                >
                  <a-button type="link">
                    选择图标
                  </a-button>
                  <div class="select-icon">
                    <div class="selected-demo">
                    <!--  -->
                    </div>
                    <div class="selected-demo">
                    <!--  -->
                    </div>
                  </div>
                </a-form-model-item>
              </a-card>
            </a-col>
          </draggable>
        </a-row>
      </a-form-model>
      <a-button type="primary" @click="add">
        添加导航
      </a-button>
    </div>
  </div>
</template>

<script>

export default {
  name: 'Navigation',
  data() {
    return {
      data: [],
      keys: 2,
      formItemLayout: {
        labelCol: { span: 6 },
        wrapperCol: { span: 18 }
      },
      form: [
        {
          name: '首页'
        },
        {
          name: '全部商品'
        },
        {
          name: '购物车'
        },
        {
          name: '我的'
        }
      ]
    }
  },
  mounted() {},
  methods: {
    handleSubmit(e) {
      e.preventDefault()
      this.form.validateFields((err, values) => {
        if (!err) {
          const { keys, names } = values
          console.log('Received values of form: ', values)
          console.log(
            'Merged values:',
            keys.map(key => names[key]),
          )
        }
      })
    },
    add() {
      this.form.push({ name: '' })
      this.rowDrop()
    }
  }
}
</script>

<style lang="less" scoped>
.navigation{
  display: flex;
  margin: 20px 0;
  padding: 20px;
  background-color: #f0f2f5;
}
.mobile-nav{
  width: 375px;
  height: 667px;
  background-color: #fff;
  position: relative;
  .mobile-header-image{
    position: absolute;
    top: 0;
    width: 100%;
    left: 0;
  }
  .mobile-footer{
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 50px;
    border-top: 1px solid #e3e2e5;
    display: flex;
    text-align: center;
    .item{
      display: flex;
      align-items: center;
      justify-content: center;
      flex: 1;
      font-size: 12px;
    }
  }
}
.mobile-config{
  width: 431px;
  margin-left: 40px;
  .panel{
    display: flex;
    height: 50px;
    align-items: center;
    padding: 0 15px;
    background: #fff;
    border-radius:10px;
    .colorScheme{
      color: #333;
    }
    .select-color{
      width: 100px;
      display: flex;
      position: relative;
      align-items: center;
      margin-left: 20px;
      cursor: pointer;
      .color-circle{
        border: 2px solid #fff;
        border-radius: 8px;
        width: 16px;
        height: 16px;
        position: relative;
        background: #999;
        &:nth-child(2){
          margin-left: -6px;
        }
      }
    }
  }
  .panel-from{
    margin-top: 15px;
  }
  .select-icon{
    display: flex;
    .selected-demo{
      margin-right: 5px;
      height: 38px;
      width: 38px;
      border: 1px solid #e3e2e5;
      border-radius: 4px;border: 1px solid #999;
      cursor: pointer;
      &:last-child{
        margin: 0;
      }
    }
  }
}
</style>
